#!/usr/bin/env perl
use 5.010;
use strict;
use warnings;
use diagnostics;
use Data::Dumper qw(Dumper);

#say 自动添加"\n"
#say "What is your name? ";
# my $name = <STDIN>;
#chomp去除末尾换行符
#chomp $name;



my $Nginx_Main_Config_Path="./nginx.conf";
#read nginx main config
open(my $fh,'<',$Nginx_Main_Config_Path)
    or die "Cloud not open file '$Nginx_Main_Config_Path' $!";
my @Nginx_Main_Config=<$fh>;
my $Nginx_Main_Config= join ("",@Nginx_Main_Config);
close $fh;
#print $Nginx_Main_Config;


my %NginxConf;
#匿名数组引用
$NginxConf{'module'}=["events","http","stream"];

foreach my $module (@{$NginxConf{'module'}}) {
    #say $module;
    @{$NginxConf{$module}{'content'}}=($Nginx_Main_Config=~m{$module +{(.*?)}}s);
}



my @test;

@test=($Nginx_Main_Config=~m{\w+ +{.*?}}sg);

print Dumper \@test;





#print Dumper \%NginxConf;

